import request from '@/utils/request'

const commonUrl="/admin/product"

//获取一级分类 GET /admin/product/getCategory1
export function getCategory1() {
  return  request({
    url: `${commonUrl}/getCategory1`,
    method: 'get'
  })
}

//获取二级分类 GET /admin/product/getCategory2/{category1Id}
export function getCategory2(category1Id) {
  return  request({
    url: `${commonUrl}/getCategory2/${category1Id}`,
    method: 'get'
  })
}

//获取二级分类 GET /admin/product/getCategory3/{category2Id}
export function getCategory3(category2Id) {
  return  request({
    url: `${commonUrl}/getCategory3/${category2Id}`,
    method: 'get'
  })
}

//根据三级分类获取属性列表信息 GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
export function getAttrList({category1Id,category2Id,category3Id}) {
  return  request({
    url: `${commonUrl}/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method: 'get'
  })
}

//新增平台属性 POST /admin/product/saveAttrInfo
//attr :
/*{
  "attrName": "斗罗大陆",
  "attrValueList": [
    {
      "valueName": "唐三"
    }
  ],
  "categoryId": 86,
  "categoryLevel": 3
}*/
export function saveAttrInfo(attr) {
  return  request({
    url: `${commonUrl}/saveAttrInfo`,
    method: 'post',
    data:attr
  })
}

//删除平台属性 DELETE /admin/product/deleteAttr/{attrId}
export function deleteAttr(attrId) {
  return  request({
    url: `${commonUrl}/deleteAttr/${attrId}`,
    method: 'delete'
  })
}
